
JapWord.Settings = new (function() {

	var $this = this;
	
	var UI = {
		btnupdateapp: "#update-app-btn",
		btnupdatedict: "#update-dict-btn"
	};
	
	this.init = function() {
		UI = JapWord.Page.initUI(UI);
		UI.btnupdateapp.observe("click", JapWord.WebApp.reloadCache);
		UI.btnupdatedict.observe("click", updateDict);
	}
	
	function updateDict() {
		new Ajax.Request(JapWord.DynURL.GET_DICTIONNARY, {
			asynchronous: false,
			onSuccess: function(response) {
				console.log(response);
				var data = response.responseJSON;
				localStorage.setItem("Dictionnary", JSON.stringify(data));
				JapWord.Dictionnary.lastUpdate = data.lastUpdate;
				JapWord.Dictionnary.entries = data.entries;
			}
		});
		alert('Dictionnaire mis à jour !');
	}
	
	document.observe("dom:loaded", this.init);
	
});